package game;

import java.awt.Graphics2D;
import java.awt.Point;
import java.util.LinkedList;

public abstract class BaseIsland 
{
	private float gold, sanitation, health, education;
	public LinkedList<Tile> Army;
	public boolean[] ListBooleans;
	int linha0,linha1,linha2,linha3;

	public float getGold() 
	{
		return gold;
	}
	public void setGold(float gold) 
	{
		this.gold = gold;
	}
	public float getEducation() 
	{
		return education;
	}
	public void setEducation(float education) 
	{
		this.education = education;
	}
	public float getHealth() 
	{
		return health;
	}
	public void setHealth(float health) 
	{
		this.health = health;
	}
	public float getSanitation() 
	{
		return sanitation;
	}
	public void setSanitation(float sanitation) 
	{
		this.sanitation = sanitation;
	}
	
	public BaseIsland(float startGold, float startEducation, float startSanitation, float startHealth)
	{
		setGold(startGold);
		setEducation(startEducation);
		setHealth(startHealth);
		setSanitation(startSanitation);
		Army = new LinkedList<Tile>();
	}

	public void Update(Level_01 level)
	{
		for(Tile t: Army)
		{
			t.Update();
		}
	}
	public void AddArmy(TileBehaviour t)
	{
		int sequence = 0;
		for(int i = 0; i< Army.size(); i++)
		{
			if(Army.get(i).position.getX() == 80 && Army.get(i).position.getY() == 160)
				sequence ++;
			
			if(Army.get(i).position.getX() == 80 && Army.get(i).position.getY() == 200)
				sequence ++;
			
			if(Army.get(i).position.getX() == 80 && Army.get(i).position.getY() == 240)
				sequence ++;
			
			if(Army.get(i).position.getX() == 80 && Army.get(i).position.getY() == 280)
				sequence ++;
		}
		switch(sequence)
		{
			case 0:
				Army.add(new Tile(new Point(80,160),t.size, Army.size() -1, t));
				System.out.println("adicionei uma tropa");
				break;
			case 1:
				Army.add(new Tile(new Point(80,200),t.size, Army.size() -1, t));
				System.out.println("adicionei uma tropa");
				break;
			case 2:
				Army.add(new Tile(new Point(80,240),t.size, Army.size() -1, t));
				System.out.println("adicionei uma tropa");
				break;
			case 3:
				Army.add(new Tile(new Point(80,280),t.size, Army.size() -1, t));
				System.out.println("adicionei uma tropa");
				break;
		}
	}
	public void AddEnemyArmy(TileBehaviour t)
	{
		int sequence = 0;
		for(int i = 0; i< Army.size(); i++)
		{
			if(Army.get(i).position.getX() == 650 && Army.get(i).position.getY() == 160)
				sequence ++;
			
			if(Army.get(i).position.getX() == 650 && Army.get(i).position.getY() == 200)
				sequence ++;
			
			if(Army.get(i).position.getX() == 650 && Army.get(i).position.getY() == 240)
				sequence ++;
			
			if(Army.get(i).position.getX() == 650 && Army.get(i).position.getY() == 280)
				sequence ++;
		};
		switch(sequence)
		{
			case 0:
				Army.add(new Tile(new Point(650,160),t.size, Army.size() -1, t));
				System.out.println("adicionei uma tropa");
				break;
			case 1:
				Army.add(new Tile(new Point(650,200),t.size, Army.size() -1, t));
				System.out.println("adicionei uma tropa");
				break;
			case 2:
				Army.add(new Tile(new Point(650,240),t.size, Army.size() -1, t));
				System.out.println("adicionei uma tropa");
				break;
			case 3:
				Army.add(new Tile(new Point(650,280),t.size, Army.size() -1, t));
				System.out.println("adicionei uma tropa");
				break;
		}
	}
	public void Draw(Graphics2D graphics)
	{
		for(Tile t : Army)
		{
			t.draw(graphics);
		}
	}
}
